import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:material_collection_app/utils/utils.dart';

class HomeDataCard extends StatelessWidget {
  final Map showData;

  HomeDataCard({Key key, this.showData}) : super(key: key);

  Widget _buildCardHead(title) {
    return Container(
      width: 680.w,
      height: 90.w,
      alignment: Alignment.centerLeft,
      child: Text(title,
        style: TextStyle(
          color: Color(0xFF333333), fontSize: 16, fontWeight: FontWeight.bold
        ),
      ),
    );
  }

  Widget _buildCard(number, text, bool line) {
    return Row(
      children: <Widget>[
        Container(
          width: 226.w,
          height: 180.w,
          alignment: Alignment.center,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(number.toString(), 
                style: TextStyle(color: Color(0xFF297CFF),fontSize: 42.w, fontWeight: FontWeight.w500),
              ),
              Container(
                margin: EdgeInsets.only(top: 20.w),
                child: Text(text,
                  style: TextStyle(color: Color(0xFF999999),fontSize: 12, height: 1),
                ),
              )
            ],
          ),
        ),
        Offstage(
          offstage: !line,
          child: Container(
            width: 2.w,
            height: 48.w,
            color: Utils.hexToColor('#F2F2F2'),
          )
        ),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 750, height: 1334, allowFontScaling: false);

    return Container(
      width: 720.w,
      height: 271.w,
      margin: EdgeInsets.fromLTRB(15.w, 384.w, 15.w, 0),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(20.w),
      ),
      child: Column(
        children: <Widget>[
          _buildCardHead('数据展示'),
          Container(
            width: 680.w,
            height: 1.w,
            decoration: BoxDecoration(
              border: Border(bottom:BorderSide(width: 1,color: Color(0xFFF1F1F1)))
            ),
          ),
          Container(
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                _buildCard(showData['enter'], '今日入库', true),
                _buildCard(showData['out'], '今日出库', true),
                _buildCard(showData['all'], '今日处置', true),
              ],
            ),
          )
        ],
      ),
    );
  }
}